using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BanZuiCloudControlAgent.Core.Mqtt.Models
{
    /// <summary>
    /// MQTT主题模板常量类，用于存储所有MQTT主题模板，避免硬编码
    /// </summary>
    public static class MqttTopicTemplates
    {
        /// <summary>
        /// 设备状态上报主题模板
        /// </summary>
        public const string STATUS_REPORT = "{prefix}/{deviceCode}/status";

        /// <summary>
        /// 任务下发主题模板
        /// </summary>
        public const string TASK_DISPATCH = "{prefix}/{deviceCode}/task";

        /// <summary>
        /// 任务上报主题模板
        /// </summary>
        public const string TASK_REPORT = "{prefix}/{deviceCode}/task/report";

        /// <summary>
        /// 配置下发主题模板
        /// </summary>
        public const string CONFIG = "{prefix}/{deviceCode}/config";

        /// <summary>
        /// 错误上报主题模板
        /// </summary>
        public const string ERROR_REPORT = "{prefix}/{deviceCode}/error";

        /// <summary>
        /// QQ在线列表上报主题模板
        /// </summary>
        public const string QQ_ONLINE_REPORT = "{prefix}/{deviceCode}/qq_list";

        /// <summary>
        /// 采集上报主题模板
        /// </summary>
        public const string COLLECT_REPORT = "{prefix}/{deviceCode}/collect";
        
        /// <summary>
        /// 更新任务主题模板
        /// </summary>
        public const string UPDATE_TASK = "{prefix}/{deviceCode}/update";

        /// <summary>
        /// 构建完整的主题路径
        /// </summary>
        /// <param name="template">主题模板</param>
        /// <param name="prefix">主题前缀</param>
        /// <param name="deviceCode">设备码</param>
        /// <returns>替换了前缀和设备码的完整主题路径</returns>
        public static string BuildTopic(string template, string prefix, string deviceCode)
        {
            return template
                .Replace("{prefix}", prefix)
                .Replace("{deviceCode}", deviceCode);
        }

        /// <summary>
        /// 获取设备需要订阅的所有主题模板列表
        /// </summary>
        /// <returns>设备需要订阅的主题模板列表</returns>
        public static List<string> GetSubscribeTopicTemplates()
        {
            return new List<string>
            {
                TASK_DISPATCH,
                CONFIG,
                UPDATE_TASK
            };
        }
    }
} 